/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.chl.cid.beans;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author rhodinj
 */
@ManagedBean
//@RequestScoped
@SessionScoped
public class LoginController {

    @EJB
    private LoginEJB loginEJB;

    private String loginname;
    private String password;
    private boolean lin = false;

    public String login()
    {
        if (loginEJB.validateUser(loginname, password))
        {
            lin = true;
            return "loginsuccess";
        } else {
            lin = false;
            return "loginfail";
        }
    }

    public String logout()
    {
        lin = false;
        return "logout";
    }

    public LoginEJB getEJB() {
        return loginEJB;
    }

    public void setEJB(LoginEJB loginEJB) {
        this.loginEJB = loginEJB;
    }

    public String getLoginname() {
        return loginname;
    }

    public void setLoginname(String loginname) {
        this.loginname = loginname;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean isLin() {
        return lin;
    }

    public void setLin(boolean lin) {
        this.lin = lin;
    }


}